'use strict';

const findOrCreate = require('../lib/mongoose/plugin_findorcreate');

module.exports = mongoose => {
  const AppSchema = new mongoose.Schema({
    uid: { type: String, unique: true }, //
    name: { type: String },
    alias: { type: String },
    type: { type: Number, ref: 'type' },
    categories: { type: Array },
    config: { type: Object },
    keywords: { type: String },
    description: { type: String },
  });

  AppSchema.plugin(findOrCreate);

  return mongoose.model('App', AppSchema);
};
